package beach;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Insert_OffcnDemo1 {//消耗了357561毫秒
    public static void main(String[] args) throws SQLException {
        ComboPooledDataSource dataSource = new ComboPooledDataSource();
        Connection con = dataSource.getConnection();
//        注意sql 语句 不要写错了 where 怎么有的sd
//        String s = "insert into offcn  where values(?,?,?,?)";
        String s = "insert into offcn values(?,?,?,?)";
        PreparedStatement ps = con.prepareStatement(s);
        long start = System.currentTimeMillis();
        //i=1开始，没有0行
        for (int i = 1; i <= 100000 ; i++) {
            ps.setInt(1,i);
            ps.setString(2,"wj"+i);
            ps.setInt(3,i+18);
            ps.setString(4,"wj" + i +"@qq.com");
           //每循环一次，执行插入一次
            ps.executeUpdate();
            if (i%2000==0){
                System.out.println("插入了" + i +"条信息");
            }
        }
        long end = System.currentTimeMillis();
        System.out.println("消耗了" + (end - start )+ "毫秒");
        ps.close();
        con.close();

    }
}
